package nccloud.web.cdmc.cdm.financepay.action;

import nccloud.dto.ifac.common.bean.IfacOperatorParam;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.convert.translate.Translator;
import nccloud.framework.web.processor.template.BillCardConvertProcessor;
import nccloud.framework.web.ui.pattern.billcard.BillCard;
import nccloud.framework.web.ui.pattern.billcard.BillCardFormulaHandler;
import nccloud.web.ifac.pub.util.NCCPageInfoUtil;
import nccloud.web.sf.allocation.allocate.util.AllocateDefaultValue4NCCUtil;
//import nc.vo.cmp.informer.AggInformerMappingVO;
import nc.vo.cmp.informer.InformerVO;
import nc.vo.pub.BusinessException;
import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.pf.IPfExchangeService;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.laf.persistence.BeanPersistence;
import nc.vo.cdmc.cdm.financepay.AggFinancepayVO;
import nc.vo.cdmc.cdm.financepay.FinancepayVO;
import nc.itf.cmp.informer.IInformerQueryService;


public class InformerToFinancepayAction implements ICommonAction{

	@Override
	public Object doAction(IRequest request) {
		// TODO Auto-generated method stub
		IfacOperatorParam parm = (IfacOperatorParam) NCCPageInfoUtil.getParam(request, IfacOperatorParam.class);
		IPfExchangeService exchange = NCLocator.getInstance().lookup(
				IPfExchangeService.class);
		BillCard billCard = null;
		String[] pks = parm.getPks();
		String pk = pks[0];
		
		InformerVO informervo = new InformerVO();
		FinancepayVO financepayvo = new FinancepayVO();
		AggFinancepayVO aggfinancepayvo = new AggFinancepayVO();
		String sql = "select * from cmp_informer where dr=0 and pk_informer = '"+pk+"'";
		IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
		try {
			informervo = (InformerVO) iuap.executeQuery(sql, new BeanProcessor(InformerVO.class));
		} catch (BusinessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		financepayvo.setPk_srcbill(pk);
		financepayvo.setPk_group(informervo.getPk_group());
		financepayvo.setPk_org(informervo.getPk_org());
		financepayvo.setPk_org_v(informervo.getPk_org_v());
		financepayvo.setSrcbillno(informervo.getVbillno());
		aggfinancepayvo.setParent(financepayvo);
		BillCardConvertProcessor processor = new BillCardConvertProcessor();
		billCard = processor.convert("36630BDLC_CARD", aggfinancepayvo);
		Translator translator = new Translator();
		translator.translate(billCard);
		BillCardFormulaHandler handler = new BillCardFormulaHandler(billCard);
		handler.handleLoadFormula();
		handler.handleBodyLoadFormula();
		try {
			AllocateDefaultValue4NCCUtil.setAllocateDefaultValue(billCard, true, false);
		} catch (BusinessException var15) {
			ExceptionUtils.wrapException(var15);
		}
		return billCard;
	}

}
